<?php
	
	 error_reporting(E_ALL);
?>

<script>
function printData(){
window.print();
}
	
	function reloadPage(){	
		var department_id =$("#department_id").val();		
		var karyawan_id =$("#karyawan_id").val();	
		var tahun_ajaran_id =$("#tahun_ajaran_id").val();	
		var semester_id =$("#semester_id").val();	
		var pelajaran_id =$("#pelajaran_id").val();	
		var kelas_id =$("#kelas_id").val();											
		var task_pelajaran_id =$("#task_pelajaran_id").val();		
		var task_pelajaran_id =$("#task_pelajaran_detail_id").val();				
		$("#tblData").jqGrid("setGridParam",{postData:{"semester_id" :$("#semester_id").val(),"pelajaran_id" :$("#pelajaran_id").val(),"kelas_tahun_ajaran_id" :$("#kelas_tahun_ajaran_id").val(),"task_pelajaran_id" :$("#task_pelajaran_id").val(),"tahun_ajaran_id" :$("#tahun_ajaran_id").val(),"task_pelajaran_detail_id" :$("#task_pelajaran_detail_id").val()},datatype:"json"}).trigger("reloadGrid",[{current:true}]);
		//$("#tblData").jqGrid("setGridParam",{postData:{"karyawan_id" :$("#karyawan_id").val()},datatype:"json"}).trigger("reloadGrid",[{current:true}]);		
		//$("#idSrcTblData").val("");
	//	 alert("semester_id" +$("#semester_id").val()+"pelajaran_id" +$("#pelajaran_id").val()+"kelas_tahun_ajaran_id" +$("#kelas_tahun_ajaran_id").val()+"task_pelajaran_id" +$("#task_pelajaran_id").val()+"tahun_ajaran_id" +$("#tahun_ajaran_id").val()+"task_pelajaran_detail_id" +$("#task_pelajaran_detail_id").val());
	} 
	  
	  
	   
 			
   
	function updateData(data,nilai,notes){
		//if (confirm("Update data ?")){	
		var department_id =$("#department_id").val();		
		var karyawan_id =$("#karyawan_id").val();	
		var tahun_ajaran_id =$("#tahun_ajaran_id").val();	
		var semester_id =$("#semester_id").val();	
		var pelajaran_id =$("#pelajaran_id").val();	
		var kelas_tahun_ajaran_id =$("#kelas_tahun_ajaran_id").val();											
		var task_pelajaran_id =$("#task_pelajaran_id").val();		
		var task_pelajaran_detail_id =$("#task_pelajaran_detail_id").val();	
		var department_id =data.department_id;		
		var karyawan_id =data.karyawan_id;	
//		var tahun_ajaran_id =data.tahun_ajaran_id;	
//		var semester_id =data.semester_id;	
//		var pelajaran_id =data.pelajaran_id;	
//		var kelas_id =data.kelas_id;											
//		var task_pelajaran_id =data.task_pelajaran_id;	
//		var task_pelajaran_detail_id =data.task_pelajaran_detail_id;	
		var sid =data.sid;			
		var stat_id =data.stat_id;			 
		var student_id =data.id;		
		var nilai =nilai;
		var notes;
//		if (notes=="empty") {note="-";} else {note=notes;}
		var is_active=1;		
		if (stat_id==0){op="add";}else{op="edit";} 	 		
			window.parent.showLoader();			
			var editUrl = $("#tblData").jqGrid("getGridParam","editUrl");
			$.ajax({	
				url : editUrl,
				type:"GET",
				async:true,
				data: {op: op,student_id:student_id,id:stat_id,stat_id:stat_id,sid:sid,nilai:nilai,karyawan_id:karyawan_id,kelas_tahun_ajaran_id:kelas_tahun_ajaran_id,task_pelajaran_detail_id:task_pelajaran_detail_id,is_active:is_active,notes:notes},
				success: function(data) {
					if(data.actionStatus == 1){
						alert(data.actionMessage);
						return false;						
					}
					else
					if(data.actionStatus == 2){
						alert(data.actionMessage);
						return false;
					}						
				},
				complete:function(){
					window.parent.hideLoader();
					reloadPage();
				}
			});			
		//}
			
	}   
	
	$(function(){
		var department_id =$("#department_id").val();		
		var karyawan_id =$("#karyawan_id").val();	
		var tahun_ajaran_id =$("#tahun_ajaran_id").val();	
		var semester_id =$("#semester_id").val();	
		var pelajaran_id =$("#pelajaran_id").val();	
		var kelas_tahun_ajaran_id =$("#kelas_tahun_ajaran_id").val();											
		var task_pelajaran_id =$("#task_pelajaran_id").val();	
		var task_pelajaran_detail_id =$("#task_pelajaran_detail_id").val();			
		var numberTemplate = {formatter: 'number', align: 'right', sorttype: 'number'};	 
		$("#tblData").jqGrid({
			url:'index.php?r=karyawan/penilaian/isi_nilai/detailList',
			editUrl:'index.php?r=karyawan/penilaian/isi_nilai/edit',
			postData:{"department_id":department_id,"karyawan_id" :karyawan_id,"tahun_ajaran_id":tahun_ajaran_id,"semester_id" :semester_id,"pelajaran_id":pelajaran_id,"kelas_tahun_ajaran_id" :kelas_tahun_ajaran_id,"task_pelajaran_id" :task_pelajaran_id,"task_pelajaran_detail_id" :task_pelajaran_detail_id},
			cellurl :"#",					
			datatype: 'json',
			loadonce:true,
			mtype:"GET",
			autowidth:true,
			height:"100%",
			altRows:true,
			ignoreCase:true,
			colNames: ['','','sid','nama','nilai','notes','','','','','','','' ,'' ],
			colModel: [
				{name: 'id', index: 'id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'stat_id', index: 'stat_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},			
				{name: 'sid', index: 'sid', width: 40,hidden:false,sorttype:'int',formatter:'int'},
				{name: 'name', index: 'name', width: 200,search:true},
				{name: 'nilai', index: 'nilai',width: 60,editable:true,editoptions:{
                                size: 25, maxlengh: 10,
                                dataInit: function(element) {
                                    $(element).keyup(function(){
                                        var val1 = element.value;
                                        var num = new Number(val1);
                                        if(isNaN(num))
                                        {alert("Please enter a valid number");}
                                    })
                                }
                            }},
				{name: 'notes', index: 'notes',width: 140,editable:true,edittype:"textarea"},				
				{name: 'semester_id', index: 'semester_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'karyawan_id', index: 'karyawan_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'pelajaran_id', index: 'pelajaran_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'task_pelajaran_id', index: 'task_pelajaran_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'department_id', index: 'department_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'tahun_ajaran_id', index: 'tahun_ajaran_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'kelas_tahun_ajaran_id', index: 'kelas_tahun_ajaran_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},	
				{name: 'task_pelajaran_detail_id', index: 'task_pelajaran_detail_id', width: 40,hidden:true,sorttype:'int',formatter:'int'},																																	
			],
		afterInsertRow: function(rowid, rowData, rowelem) {
		   var detail= rowData['nilai'];
		   if(detail>60){
		$(this).jqGrid('setRowData', rowid, false, { color: '#000' });
		  }else {
		$(this).jqGrid('setRowData', rowid, false, { color: '#FF0000' });
			}
			},			
		forceFit : true, cellEdit: true, cellsubmit: 'clientArray',
				afterSaveCell : function(rowid,name,val,iRow,iCol) { 
					 var aDataIDs =  $('#tblData').getDataIDs();
					 var oRow = $('#tblData').getRowData(aDataIDs[iRow-1]);
					 if (oRow.notes==""){notes="-";}else{notes=oRow.notes;}
					if(name == 'nilai') 
					{ 					
						updateData(oRow,val,notes);
					}
					else
					{
						updateData(oRow,oRow.nilai,val);					
					}
				},					
			gridview: true,
			rownumbers: false,
			rowNum: 10,
			rowList: [5, 10, 15],
			pager: '#navTblData',
			viewrecords: true,
			caption: 'Penilaian Pelajaran',
			jsonReader : { 
				root:"model",
				repeatitems: false			
			},
			loadComplete:function(data){
				console.log(data);
				
			}, 
			
			gridComplete: function(){ 
		 
			}
		});
		$("#tblData").jqGrid('navGrid','#navTblData',{add:false,edit:false,search:false,del:false,refresh:false});
		
		//add search text
		$("#tblData").jqGrid('addSearchText',["name"]);
		
		
	});  
</script>
	<script>
	 
function Department_OnChange_fill_all(){ 
	window.parent.showLoader();	
		$filter = {"is_active":1,"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"tahun_ajaran_id",title_field:"tahun_ajaran_name",group:"tahun_ajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#tahun_ajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		
					
		$filter = {"is_active":1,"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"MSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#semester_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		
		$filter = {"is_active":1,"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"tingkatan_id",title_field:"tingkatan_name",group:"tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#tingkatan_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
				
		$filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"kelas_tahun_ajaran_id",title_field:"kelas_name",group:"kelas_id,tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#kelas_tahun_ajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		 
		$filter = {"is_active":1,"karyawan_id":$("#karyawan_id").val(),"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
	 
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"pelajaran_id",title_field:"pelajaran_name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
		$filter = {"is_active":1,"pelajaran_id":$("#pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"task_pelajaran_id",title_field:"task_name",group:"task_pelajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});							 
}	

function Tahun_Ajaran_OnChange_fill_all(){ 
	window.parent.showLoader();	
		$filter = {"is_active":1,"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"MSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#semester_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		
		$filter = {"is_active":1,"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"tingkatan_id",title_field:"tingkatan_name",group:"tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#tingkatan_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
				
		$filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"kelas_tahun_ajaran_id",title_field:"kelas_name",group:"kelas_id,tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#kelas_tahun_ajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		 
		$filter = {"is_active":1,"karyawan_id":$("#karyawan_id").val(),"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
	 
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"pelajaran_id",title_field:"pelajaran_name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
		$filter = {"is_active":1,"pelajaran_id":$("#pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"task_pelajaran_id",title_field:"task_name",group:"task_pelajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});							 
}			

function Semester_OnChange_fill_all(){ 
	window.parent.showLoader();	
		$filter = {"is_active":1,"pelajaran_id":$("#pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"task_pelajaran_id",title_field:"task_name",group:"task_pelajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
}		
function Tingkatan_OnChange_fill_Task_Detail(){ 
	window.parent.showLoader();	
		$filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			//data: {filter: "is_active=true and department_id = '" + $("#department_id").val() + "' union select id,name,1,1,null,null,1,1,1 from m_kelas" },
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"kelas_tahun_ajaran_id",title_field:"kelas_name",group:"kelas_id,tingkatan_id" },
			success: function(data) {
				printConsole(data);
				fillSelectData("#kelas_tahun_ajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
		 
		$filter = {"is_active":1,"karyawan_id":$("#karyawan_id").val(),"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
	 
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"pelajaran_id",title_field:"pelajaran_name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
		$filter = {"is_active":1,"pelajaran_id":$("#pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"task_pelajaran_id",title_field:"task_name",group:"task_pelajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});							 
}		
 
 
 

function  KelasTahunAjaran_OnChange_fill_Task_Detail(){ 
	window.parent.showLoader();	
		$filter = {"is_active":1,"karyawan_id":$("#karyawan_id").val(),"tingkatan_id":$("#tingkatan_id").val(),"kelas_tahun_ajaran_id":$("#kelas_tahun_ajaran_id").val(),"tahun_ajaran_id":$("#tahun_ajaran_id").val(),"department_id":$("#department_id").val()};
	 
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VJadwalPelajaranKelasTahunAjaran",filter: $filter,value_field:"pelajaran_id",title_field:"pelajaran_name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});		
		
		$filter = {"is_active":1,"pelajaran_id":$("#pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"task_pelajaran_id",title_field:"task_name",group:"task_pelajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});						 
} 

 function Pelajaran_OnChange_fill_Task_Detail(){
 
		window.parent.showLoader();	
		$filter = {"is_active":1,"pelajaran_id":$("#pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"task_pelajaran_id",title_field:"task_name",group:"task_pelajaran_id"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});	
	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});									
		 
	}   

 function Task_Pelajaran_OnChange_fill_Task_Detail(){
		window.parent.showLoader();	
		$filter = {"is_active":1,"task_pelajaran_id":$("#task_pelajaran_id").val(),"semester_id":$("#semester_id").val()};
		$.ajax({	
			url : "index.php?r=Data_select/selectDataAjxResult",
			type:"GET",
			async:false,
			data: {obj:"VTaskPelajaranDetailSemester",filter: $filter,value_field:"id",title_field:"name"},
			success: function(data) {
				printConsole(data);
				fillSelectData("#task_pelajaran_detail_id",data);	
				reloadPage();
			},
			complete:function(){
				window.parent.hideLoader();
			}
		});										
	}   	
</script>
 

<div>
    <?php 
		$this->widget('application.components.widgets.TextField', 
			array("name"=>"karyawan_name",
				"value"=>$karyawan_name,
				"htmlOptions"=>"size='20'",
				"htmlOptions"=>"disabled",				
				"label"=>array(
					"value"=>Yii::t("label","Guru"),
					"htmlOptions"=>"class='form' style='width:100px;'"
				)
			)
		);		
    ?>		
    <input type="hidden" id="karyawan_id" name="karyawan_id" value="<?php echo $karyawan_id ?>"  />
    <input type="hidden" id="karyawan_name" name="karyawan_name" value="<?php echo $karyawan_name ?>"  />

</div>    
 

  
<div style="float:rigth">&nbsp;
<?php 
    $this->widget('application.components.widgets.ActionBar', 
        array("menuAlign" => "right", 
            'items' => array(
                array(
                    'id' => "btnRefresh",
                    'title' => Yii::t("menu","Segarkan"),
                    'icon' => "images/action/Action-Refresh-icon.png",
                    'callback'=>"reloadPage"
                ),	/*				
                array(
                    'id' => "btnNew",
                    'title' => Yii::t("menu","Baru"),
                    'icon' => "images/action/Actions-document-new-icon.png",
                    'callback'=>"newData"
                ), */
                array(
                    'id' => "btnNew",
                    'title' => Yii::t("menu","Cetak"),
                    'icon' => "images/action/Actions-document-print-icon2.png",
                    'callback'=>"printData"
                ),					
                 
            ) 
        )
    );
?>
</div>	
 
 	<div style="clear:both"></div>	
<div style="float:left;width:22%;">
 <div>
 		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Department") ?></label>	
		<select name="department_id" id="department_id" onchange="Department_OnChange_fill_all()"   >
			<?php
				foreach ($departments as $department){
					$selected = $department_id == $department["department_id"] ? "selected" : "";				
					echo"<option value='$department[department_id]' $selected  >$department[department_id]</option>";
				}
			?>
		</select> 
</div>        
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Tahun Ajaran") ?></label>	
		<select name="tahun_ajaran_id" id="tahun_ajaran_id" onChange="Tahun_Ajaran_OnChange_fill_all()">
			<?php
				foreach ($tahunAjarans as $tahunAjaran){
					$selected = $tahun_ajaran_id == $tahunAjaran["tahun_ajaran_id"] ? "selected" : "";				
					echo"<option value='$tahunAjaran[tahun_ajaran_id]' $selected>$tahunAjaran[tahun_ajaran_name]</option>";
				}
			?>
		</select>
	</div>
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Semester") ?></label>	
		<select name="semester_id" id="semester_id"   onchange="Semester_OnChange_fill_all()"   >
			<?php
				foreach ($semesters as $semester){
					$selected = $semester_id == $semester["id"] ? "selected" : "";				
					echo"<option value='$semester[id]' $selected>$semester[name]</option>";
				}
			?>
		</select>
	</div>	
 	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Tingkatan") ?></label>	
		<select name="tingkatan_id" id="tingkatan_id"   onchange="Tingkatan_OnChange_fill_Task_Detail()"  >
			<?php
				foreach ($tingkatans as $tingkatan){
					$selected = $tingkatan_id == $tingkatan["tingkatan_id"] ? "selected" : "";				
					echo"<option value='$tingkatan[tingkatan_id]' $selected>$tingkatan[tingkatan_name]</option>";
				}
			?>
		</select>
	</div>       
           
  	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Kelas") ?></label>	
		<select name="kelas_tahun_ajaran_id" id="kelas_tahun_ajaran_id"   onchange="KelasTahunAjaran_OnChange_fill_Task_Detail()"  >
			<?php
				foreach ($kelass as $kelas){
					$selected = $kelas_tahun_ajaran_id == $kelas["kelas_tahun_ajaran_id"] ? "selected" : "";				
					echo"<option value='$kelas[kelas_tahun_ajaran_id]' $selected>$kelas[kelas_name]</option>";
				}
			?>
		</select>
	</div>       
     
  
  	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Pelajaran") ?></label>	
 		<select name="pelajaran_id" id="pelajaran_id"  onChange="Pelajaran_OnChange_fill_Task_Detail()"   >
			<?php
				foreach ($pelajarans as $pelajaran){
					$selected = $pelajaran_id == $pelajaran["pelajaran_id"] ? "selected" : "";				
					echo"<option value='$pelajaran[pelajaran_id]' $selected>$pelajaran[pelajaran_name]</option>";
				}
			?>
		</select>
	</div>   
   
  	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Task Pelajaran") ?></label>	
		<select name="task_pelajaran_id" id="task_pelajaran_id"    onChange="Task_Pelajaran_OnChange_fill_Task_Detail()">
			<?php
				foreach ($task_pelajarans as $task_pelajaran){
					$selected = $task_pelajaran_id == $task_pelajaran["task_pelajaran_id"] ? "selected" : "";				
					echo"<option value='$task_pelajaran[task_pelajaran_id]' $selected>$task_pelajaran[task_name]</option>";
				}
			?>
		</select>
	</div>   
   
   
  	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label", "Task Pelajaran Detail") ?></label>	
		<select name="task_pelajaran_detail_id" id="task_pelajaran_detail_id"  onchange="reloadPage();"   >
			<?php
				foreach ($task_pelajaran_details as $task_pelajaran_detail){
					$selected = $task_pelajaran_detail_id == $task_pelajaran_detail["id"] ? "selected" : "";				
					echo"<option value='$task_pelajaran_detail[id]' $selected>$task_pelajaran_detail[name]</option>";
				}
			?>
		</select>
	</div>   
                     	  
             
</div>
<div style="float:left; width:78%">    
	<table id="tblData"><tr></tr></table>
	<div id="navTblData"></div>
 </div>
  